<?php
namespace app\common\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule =   [
        'id'                              => 'require|integer',
        'user_id|用户ID'                   => 'require|integer',
        'doctor_no|情博士号'               => 'require|integer',
        'page|页数'                        => 'require|integer',
        'limit|条数'                       => 'require|integer',
        'phone|手机号'                     => 'require',
        'code|验证码'                      => 'require|length:4',
        'nickname|昵称'                    => 'require|length:2,20',
        'password|密码'                    => 'require|length:5,20',
        'sex|性别'                         => 'require|in:1,2',
        'birthday|生日'                    => 'require|integer',
        'love_exp|恋爱经历'                => 'require|length:1,500',
        'marry_status|婚姻状态'            => 'require|in:1,2,3,4',
        'children_status|子女'             => 'length:0,50',
        'is_birth|婚后是否需要生育'         => 'in:1,0',
        'is_old_live|婚后是否与老人同住'    => 'in:1,0',
        'edu_status|学历'                  => 'require|length:1,50',
        'middle_school|初中'               => 'length:1,50',
        'high_school|高中'                 => 'length:1,50',
        'university|大学'                  => 'length:1,50',
        'university_up|进修学府'            => 'length:1,50',
        'major|专业'                        => 'length:1,50',
        'address_home|家乡'                 => 'require|length:1,100',
        'address_seat|所在地'               => 'require|length:1,100',
        'job|职业'                          => 'require|length:1,50',
        'job_type|职位'                     => 'require|length:1,50',
        'height|身高'                       => 'require|length:1,10',
        'weight|体重'                       => 'require|length:1,10',
        'income|收入水平'                   => 'require|length:1,50',
        'room_status|住房情况'              => 'require|length:1,50',
        'travel_status|出行工具'            => 'require|length:1,50',
        'email|邮箱'                        => 'require|email',
    ];
    
    protected $scene = [
        /** 接口 */
        'show'       => ['user_id'],
        'phone'      => ['phone'],
        'register'   => ['phone', 'code', 'doctor_no', 'password'],
        'forget'     => ['phone', 'code', 'password'],
        'login'      => ['phone', 'password'],
        'set_news'   => ['user_id', 'nickname', 'sex', 'birthday', 'love_exp', 'marry_status', 'children_status', 'is_birth', 'is_old_live', 'edu_status', 'middle_school', 'high_school', 'university', 'university_up', 'major', 'address_home', 'address_seat', 'job', 'job_type', 'height', 'weight', 'income', 'room_status', 'travel_status', 'email'],

        /** 后台 */
        'list'       => ['page', 'limit'],
    ];
}